package cn.com.fattiger.framework.cms.admin.common.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.com.fattiger.framework.cms.admin.common.dao.UserRepository;
import cn.com.fattiger.framework.cms.admin.common.model.User;
import cn.com.fattiger.framework.cms.admin.common.service.UserService;

/**
 * Created by Administrator on 2015/11/27.
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserRepository userRepository;

    @Override
    public void addUser(User user) {
        userRepository.save(user);
    }

    @Override
    public void deleteUser(Integer id) {
        userRepository.delete(id);
    }

    @Override
    public User getUser(Integer id) {
        return userRepository.getUserById(id);
    }

    @Override
    public List<User> queryUsers() {
        return userRepository.findAll();
    }

    @Override
    public List<User> login(String name, String pass) {
        return userRepository.findUserByNameAndPass(name,pass);
    }
}
